package org.rency.crawler.domain.state;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * 描述: ${TODO}<br>
 * 最近修改时间:2017/11/20 18:20<br>
 *
 * @author CaiyuRen
 * @version V1.0
 * @since 2017/11/20 18:20
 */
public enum FetchStateKind {

  STAR("101","抓取前置"),
  END("109","抓取后置"),
  ;

  private String code;
  private String msg;

  private FetchStateKind(String code, String msg){
    this.code = code;
    this.msg = msg;
  }

  public String getCode() {
    return code;
  }

  public String getMsg() {
    return msg;
  }

  public static FetchStateKind get(String code){
    if(StringUtils.isBlank(code)){
      return null;
    }
    for(FetchStateKind state : FetchStateKind.values()){
      if(state.code.equalsIgnoreCase(code)){
        return state;
      }
    }
    return null;
  }

  @Override
  public String toString() {
    return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
  }
}
